package ${basePackage}.controller.${mouduleName};

import ${basePackage}.model.${mouduleName}.${className};
import ${basePackage}.service.${mouduleName}.${className}Service;
import org.spring.springboot.core.vo.Response;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/api/${tableComment}")
public class ${className}Controller {

    @Resource
    ${className}Service ${variableName}Service;

    @GetMapping("/queryList")
    public String queryList() {
        return "${variableName}:list";
    }

    @GetMapping("/${variableName}List")
    @ResponseBody
    public Response ${variableName}List() {
        return Response.createSuccess(${variableName}Service.queryList(null));
    }

    @GetMapping("/query")
    @ResponseBody
    public Response query(Long id) {
        return Response.createSuccess(${variableName}Service.query(id));
    }

    @PostMapping("/save")
    @ResponseBody
    public Response save(${className} ${variableName}) {
        ${variableName}Service.saveOrUpdate(${variableName});
        return Response.createSuccess();
    }

    @PostMapping("/del")
    @ResponseBody
    public Response del(Long id) {
        ${variableName}Service.delete(id);
        return Response.createSuccess();
    }
}
